<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增服务分类')" />
    <th:block th:include="include :: bootstrap-fileinput-css"/>
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-serviceType-add">
            <div class="form-group">
                <label class="col-sm-3 control-label">服务分类名称：</label>
                <div class="col-sm-8">
                    <input name="serviceName" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">上级服务分类：</label>
                <div class="col-sm-8">
                    <div class="input-group">
                        <input id="treeId" name="parentId" type="hidden" th:value="${zsyhServiceType?.id}"/>
                        <input class="form-control" type="text" onclick="selectServiceTypeTree()" id="treeName" readonly="true" th:value="${zsyhServiceType?.serviceName}">
                        <span class="input-group-addon"><i class="fa fa-search"></i></span>
                    </div>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">服务分类图标：</label>
                <div class="col-sm-8">
                    <input type="hidden" name="serviceImage">
                    <div class="file-loading">
                        <input class="form-control file-upload" id="serviceImage" name="file" type="file">
                    </div>
                </div>
            </div>
            <!--<div class="form-group">
                <label class="col-sm-3 control-label">服务类型等级：</label>
                <div class="col-sm-8">
                    <input name="serviceLevel" class="form-control" type="text">
                </div>
            </div>-->
            <div class="form-group">
                <label class="col-sm-3 control-label">固定抽成金额：</label>
                <div class="col-sm-8">
                    <input name="serviceFixdraw" class="form-control" type="text">
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: bootstrap-fileinput-js"/>
    <script th:inline="javascript">
        var prefix = ctx + "zsyh/serviceType"
        $("#form-serviceType-add").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/add", $('#form-serviceType-add').serialize());
            }
        }

        $(".file-upload").fileinput({
            uploadUrl: ctx + 'common/uploadOSS',
            maxFileCount: 1,
            autoReplace: true
        }).on('fileuploaded', function (event, data, previewId, index) {
            $("input[name='" + event.currentTarget.id + "']").val(data.response.url)
        }).on('fileremoved', function (event, id, index) {
            $("input[name='" + event.currentTarget.id + "']").val('')
        })

        /*服务分类-新增-选择父服务分类树*/
        function selectServiceTypeTree() {
            var options = {
                title: '服务分类选择',
                width: "380",
                url: prefix + "/selectServiceTypeTree/" + $("#treeId").val(),
                callBack: doSubmit
            };
            $.modal.openOptions(options);
        }

        function doSubmit(index, layero){
            var body = layer.getChildFrame('body', index);
               $("#treeId").val(body.find('#treeId').val());
               $("#treeName").val(body.find('#treeName').val());
               layer.close(index);
        }
    </script>
</body>
</html>